package screens
{
	import flash.desktop.NativeApplication;
	
	import starling.display.Button;
	import starling.display.Image;
	import starling.display.Quad;
	import starling.display.Sprite;
	import starling.events.Event;
	
	public class ExitGame extends Sprite
	{
		private var exitBtn:Button;
		private var playBtn:Button;
		public function ExitGame()
		{
			this.addEventListener(Event.ADDED_TO_STAGE,addToStage);
		}
		
		private function addToStage(e:Event):void
		{
			var quad:Quad = new Quad(stage.stageWidth,stage.stageHeight,0x000000);
			quad.alpha=0.5;
			addChild(quad);
			
			this.exitBtn = new Button(Assets.getAtlas().getTexture("about_backButton"));
			addChild(exitBtn);
			exitBtn.x = stage.stageWidth * 0.33 - exitBtn.width * 0.5;
			exitBtn.y = stage.stageHeight * 0.5 - exitBtn.height * 0.5;
			this.playBtn = new Button(Assets.getAtlas().getTexture("welcome_playButton"));
			addChild(playBtn);
			playBtn.x = stage.stageWidth * 0.66 - playBtn.width * 0.5;
			playBtn.y = stage.stageHeight * 0.5 - playBtn.height * 0.5;
			
			this.playBtn.addEventListener(Event.TRIGGERED,playHandler);
			this.exitBtn.addEventListener(Event.TRIGGERED,exitHandler);
			
			this.visible = false;
		}
		
		private function exitHandler(e:Event):void
		{
			NativeApplication.nativeApplication.exit();
		}
		
		private function playHandler(e:Event):void
		{
			this.visible = false;
		}
	}
}